<?php
/*
*	Kleophatra - Open Source Content Management System
*	------------------------------------------------------------------------
*	Copyright (C) 2007-2009, Sergio Milardovich <smilardovich@yahoo.com.ar>
*	This program is Free Software.
*	Show topics widget
*
*	@package	Kleophatra
*	@subpackage	/modules
*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
*	@author		Sergio Milardovich <smilardovich@yahoo.com.ar>
*	@link		http://www.kleophatra.org
*/
	$output;
	$ref = $_SESSION['widget_ref']['blog->show_topics'];
	$widget_form['blog->show_topics'] =  array(
   		"Limit" => array("widget_latest_topics_limit","text"),
   		"Order by" => array("widget_latest_topics_orderby", "text")
	);

	// Check the limit...
	if($this->is_value("widget_latest_topics_limit",$ref)){
		$limit = $this->get_core_value("widget_latest_topics_limit", "name", $ref);
	} else {
		$limit = $this->add_core_value("widget_latest_topics_limit", 15, $ref);
	}
	//Check order by
	if(!$this->is_value("widget_latest_topics_orderby",$ref)){
		$this->add_core_value('widget_latest_topics_orderby','topicid DESC', $ref);
	}
	$orderby = $this->get_core_value("widget_latest_topics_orderby", "name", $ref);
	$output .= '<ul class="topics_list">';
	$wquery = $this->query("SELECT * FROM ".KLEO_TABLE_PREFIX."topics ORDER BY $orderby LIMIT $limit");
	while($wrow = $this->fetch_array($wquery)){
		$output .= '<li><a href="index.php?module=blog&cat='.$wrow['topicid'].'">'.$wrow['tname'].'</a></li>';
	}
	$output .= '</ul>';